//
//  Nurse.m
//  05-循环遍历
//
//  Created by dllo on 16/7/8.
//  Copyright © 2016年 高雅馨. All rights reserved.
//

#import "Nurse.h"

@implementation Nurse
-(instancetype)initWithName:(NSString *)name Age:(NSInteger)age {
    self = [super init];
    if (self) {
        // 点语法 -> setter方法
        _name = name;
        // 直接给实例变量赋值
        self.age = age;
    }return self;
}
+(instancetype)nurseWithName:(NSString *)name Age:(NSInteger)age {
    return [[Nurse alloc] initWithName:name Age:age];
}
/* 为了方法选择器可以识别, 自定义方法需要仿照系统的比较方法去实现(返回值类型是NSComparisonResult!!!!*/
-(NSComparisonResult)sortByAge:(Nurse *)nurse {
    if (self.age < nurse.age) {
        return NSOrderedAscending;
    }else if (self.age == nurse.age){
        return NSOrderedSame;
    }else{
        return NSOrderedDescending;
    }
}
-(NSComparisonResult)sortByName:(Nurse *)nurse {
    return [self.name compare:nurse.name];
}
- (NSString *)description
{
    return [NSString stringWithFormat:@"当前人的年龄为%ld", _age];
}
@end
